﻿@page
@using Microsoft.Extensions.Options
@using reCAPTCHA.AspNetCore
@using WB.UI.Designer.Models
@model LoginModel
@inject IOptions<RecaptchaSettings> CaptchaConfig;

@{
    ViewData["Title"] = AccountResources.Login;
}

    <form method="post" id="start-log-in" autocomplete="off">
        <h1>
            @AccountResources.Welcome<br />
            @AccountResources.AppName
        </h1>
        <p class="note">
            @AccountResources.LoginMessage
            <a asp-page="./Register">
                @AccountResources.Register
            </a>
        </p>

        @if (Model.ErrorMessage != null)
        {
            <p class="note has-error">
                @Html.Raw(Model.ErrorMessage)

                @if (Model.ShowActivationLink)
                {
                    <a asp-page="./ResendConfirmationLink" asp-route-id="@Model.Input.Email">
                        @ErrorMessages.RequestAnotherEmail
                    </a>
                }
            </p>
        }
        
        <div asp-validation-summary="All" class="text-danger"></div>

        <div class="form-group">
            <input asp-for="Input.Email" class="form-control" placeholder="@AccountResources.LoginOrEmail" />
            <span asp-validation-for="Input.Email" class="text-danger help-inline"></span>
        </div>
        <div class="form-group">
            <input asp-for="Input.Password" class="form-control" placeholder="@AccountResources.Password" />
            <span asp-validation-for="Input.Password" class="text-danger help-inline"></span>
        </div>

        <div>
            <input class="wb-checkbox" id="ShowPassword" type="checkbox" 
                onclick="var pass = document.getElementById('Input_Password');pass.type = (pass.type === 'text' ? 'password' : 'text');">
            <label for="ShowPassword" style="margin-bottom: 0;">
                <span></span>@AccountResources.ShowPassword
            </label>
        </div>
        <div class="form-group">
            <input asp-for="Input.RememberMe" class="wb-checkbox" placeholder="@AccountResources.StaySignedIn" />

            <label asp-for="Input.RememberMe">
                <span></span>@AccountResources.StaySignedIn
            </label>

            <br>
        </div>

        @if (this.Model.ShouldShowCaptcha)
        {
            <div class="recaptcha">
                @Html.Recaptcha(CaptchaConfig.Value)
            </div>
        }
        <div class="form-actions">
            <input class="btn btn-success btn-lg" type="submit" value="@AccountResources.Login" />
            <a class="btn btn-link" asp-page="./ForgotPassword">@AccountResources.ForgotPassword</a>
        </div>
    </form>

@section Scripts {
    <partial name="_ValidationScriptsPartial" />
}
